<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: pink;
            border-radius: 100%;

        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        const colors = {
            pink : Symbol(),
            black : Symbol(),
            green : Symbol(),
            red : Symbol()
        }
        //假设 首次为pink
        var color = colors.pink
        //获取页面元素
        var box = document.querySelector('#box')
        //添加点击事件
        box.onclick = function () {
            switch(color){
                case colors.pink:
                box.style.backgroundColor = 'black'
                color = colors.black
                break
                case colors.black:
                box.style.backgroundColor = 'green'
                color = colors.green
                break
                case colors.green:
                box.style.backgroundColor = 'red'
                color = colors.red
                break
                case colors.red:
                box.style.backgroundColor = 'pink'
                color = colors.pink
                break
            }
        }
    </script>
</body>
</html>